<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/cuphead.ico?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/cuphead.ico?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/cuphead.ico?v=5.1.3">


  <link rel="mask-icon" href="/cuphead.ico?v=5.1.3" color="#222">





  <meta name="keywords" content="运维,oracle,">










<meta name="description" content="本文是本人在运维过程中常用的脚本">
<meta name="keywords" content="运维,oracle">
<meta property="og:type" content="article">
<meta property="og:title" content="ORACLE 运维命令">
<meta property="og:url" content="https://mylyed.github.io/2017/06/16/oracle-operations/index.html">
<meta property="og:site_name" content="李磊的笔记本">
<meta property="og:description" content="本文是本人在运维过程中常用的脚本">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-04-27T14:37:16.410Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ORACLE 运维命令">
<meta name="twitter:description" content="本文是本人在运维过程中常用的脚本">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://mylyed.github.io/2017/06/16/oracle-operations/">





  <title>ORACLE 运维命令 | 李磊的笔记本</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">李磊的笔记本</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">纸上得来终觉浅，绝知此事要躬行。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://mylyed.github.io/2017/06/16/oracle-operations/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李磊">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="李磊的笔记本">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">ORACLE 运维命令</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-06-16T09:35:30+08:00">
                2017年06月16号
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv">本文总阅读量
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>次
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>本文是本人在运维过程中常用的脚本<br><a id="more"></a></p>
<h3 id="bash脚本"><a href="#bash脚本" class="headerlink" title="bash脚本"></a>bash脚本</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">--查看数据库字符集</span></span><br><span class="line"><span class="keyword">select</span> userenv(<span class="string">'language'</span>) nls_lang <span class="keyword">from</span> dual;</span><br><span class="line"></span><br><span class="line"><span class="comment">--dmp文件第2、3字节记录的字符集</span></span><br><span class="line"><span class="keyword">select</span> nls_charset_name(to_number(<span class="string">'0354'</span>,<span class="string">'xxxx'</span>)) <span class="keyword">from</span> dual;</span><br><span class="line"></span><br><span class="line"><span class="comment">--关闭、启用外键</span></span><br><span class="line"><span class="keyword">select</span> <span class="string">'alter table '</span>||table_name||<span class="string">' enable constraint '</span>||constraint_name||<span class="string">';'</span> <span class="keyword">from</span> user_constraints <span class="keyword">where</span> constraint_type=<span class="string">'R'</span>;</span><br><span class="line"><span class="keyword">select</span> <span class="string">'alter table '</span>||table_name||<span class="string">' disable constraint '</span>||constraint_name||<span class="string">';'</span> <span class="keyword">from</span> user_constraints <span class="keyword">where</span> constraint_type=<span class="string">'R'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--禁用、启用用户创建的触发器</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="string">'alter trigger '</span>|| OBJECT_NAME ||<span class="string">' disable;'</span> <span class="keyword">FROM</span> DBA_OBJECTS <span class="keyword">WHERE</span> OBJECT_TYPE=<span class="string">'TRIGGER'</span> <span class="keyword">and</span> owner=<span class="string">'YO_ONLINE'</span> <span class="keyword">order</span> <span class="keyword">by</span> OBJECT_NAME;</span><br><span class="line"><span class="keyword">SELECT</span> <span class="string">'alter trigger '</span>|| OBJECT_NAME ||<span class="string">' enable;'</span> <span class="keyword">FROM</span> DBA_OBJECTS <span class="keyword">WHERE</span> OBJECT_TYPE=<span class="string">'TRIGGER'</span> <span class="keyword">and</span> owner=<span class="string">'YO_ONLINE'</span> <span class="keyword">order</span> <span class="keyword">by</span> OBJECT_NAME;</span><br><span class="line"></span><br><span class="line"><span class="comment">--删除表数据</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="string">'truncate table '</span>||table_name||<span class="string">';'</span> <span class="keyword">FROM</span> ALL_TABLES <span class="keyword">WHERE</span> OWNER=<span class="string">'YO_TEST'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">select</span> <span class="string">'drop table '</span>||table_name||<span class="string">';'</span> <span class="keyword">FROM</span> ALL_TABLES <span class="keyword">WHERE</span> OWNER=<span class="string">'YO_TEST'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">SELECT</span> ATS.NUM_ROWS,ATS.TABLE_NAME <span class="keyword">FROM</span> ALL_TABLES ATS <span class="keyword">WHERE</span> ATS.OWNER=<span class="string">'YO_ONLINE'</span> <span class="keyword">ORDER</span> <span class="keyword">BY</span> ATS.TABLE_NAME <span class="keyword">ASC</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--设置显示宽度、长度</span></span><br><span class="line"><span class="keyword">show</span> pagesize; <span class="comment">--查看目前的pagesize</span></span><br><span class="line"><span class="keyword">set</span> pagesize <span class="number">300</span>; <span class="comment">--设置pagesize为300</span></span><br><span class="line"><span class="keyword">show</span> linesize; <span class="comment">--查看当前的linesize宽度</span></span><br><span class="line"><span class="keyword">set</span> linesize <span class="number">300</span>; <span class="comment">--设置linesize宽度</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--修改字符集</span></span><br><span class="line">sqlplus /nolog</span><br><span class="line">SQL&gt;connect sys/sys as sysdba</span><br><span class="line">SQL&gt;SHUTDOWN IMMEDIATE</span><br><span class="line">SQL&gt;STARTUP MOUNT;</span><br><span class="line">SQL&gt;ALTER SYSTEM ENABLE RESTRICTED SESSION;  </span><br><span class="line">SQL&gt;ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;</span><br><span class="line">SQL&gt;ALTER SYSTEM SET AQ_TM_PROCESSES=0;</span><br><span class="line">SQL&gt;ALTER DATABASE OPEN;</span><br><span class="line">SQL&gt;ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK; //跳过超子集检测</span><br><span class="line">SQL&gt;ALTER DATABASE national CHARACTER SET INTERNAL ZHS16GBK;</span><br><span class="line">SQL&gt;SHUTDOWN IMMEDIATE;</span><br><span class="line">SQL&gt;STARTUP</span><br><span class="line">=================================</span><br><span class="line">SQL&gt; conn /as sysdba</span><br><span class="line">======================================</span><br><span class="line">Connected.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; shutdown immediate;</span><br><span class="line">================================</span><br><span class="line">Database closed.</span><br><span class="line"></span><br><span class="line">Database dismounted.</span><br><span class="line"></span><br><span class="line">ORACLE instance shut down.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; startup mount</span><br><span class="line">================================</span><br><span class="line">ORACLE instance started.</span><br><span class="line"></span><br><span class="line">Total System Global Area  236000356 bytes</span><br><span class="line"></span><br><span class="line">Fixed Size                   451684 bytes</span><br><span class="line"></span><br><span class="line">Variable Size             201326592 bytes</span><br><span class="line"></span><br><span class="line">Database Buffers           33554432 bytes</span><br><span class="line"></span><br><span class="line">Redo Buffers                 667648 bytes</span><br><span class="line"></span><br><span class="line">Database mounted.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; ALTER SYSTEM ENABLE RESTRICTED SESSION;</span><br><span class="line">================================</span><br><span class="line">System altered.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;</span><br><span class="line">================================</span><br><span class="line">System altered.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; ALTER SYSTEM SET AQ_TM_PROCESSES=0;</span><br><span class="line">================================</span><br><span class="line">System altered.</span><br><span class="line"></span><br><span class="line">SQL&gt; alter database open;</span><br><span class="line"></span><br><span class="line">Database altered.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; ALTER DATABASE CHARACTER SET AL32UTF8; --ZHS16GBK;</span><br><span class="line">================================</span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="built_in">CHARACTER</span> <span class="keyword">SET</span> ZHS16GBK</span><br><span class="line"></span><br><span class="line">*</span><br><span class="line"></span><br><span class="line"><span class="keyword">ERROR</span> <span class="keyword">at</span> line <span class="number">1</span>:</span><br><span class="line"></span><br><span class="line">ORA<span class="number">-12712</span>: <span class="keyword">new</span> <span class="built_in">character</span> <span class="keyword">set</span> must be a superset <span class="keyword">of</span> <span class="keyword">old</span> <span class="built_in">character</span> <span class="keyword">set</span></span><br><span class="line"></span><br><span class="line">提示我们的字符集：新字符集必须为旧字符集的超集，这时我们可以跳过超集的检查做更改：</span><br><span class="line">================================</span><br><span class="line"><span class="keyword">SQL</span>&gt; <span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="built_in">character</span> <span class="keyword">set</span> INTERNAL_USE AL32UTF8;  <span class="comment">--ZHS16GBK;</span></span><br><span class="line">================================</span><br><span class="line">Database altered.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; select * from v$nls_parameters;</span><br><span class="line">================================</span><br><span class="line">略</span><br><span class="line"></span><br><span class="line">19 rows selected.</span><br><span class="line"></span><br><span class="line">重启检查是否更改完成：</span><br><span class="line">================================</span><br><span class="line">SQL&gt; shutdown immediate;</span><br><span class="line">================================</span><br><span class="line">Database closed.</span><br><span class="line"></span><br><span class="line">Database dismounted.</span><br><span class="line">ORACLE instance shut down.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; startup</span><br><span class="line">================================</span><br><span class="line">ORACLE instance started.</span><br><span class="line">Total System Global Area  236000356 bytes</span><br><span class="line">Fixed Size                   451684 bytes</span><br><span class="line">Variable Size             201326592 bytes</span><br><span class="line">Database Buffers           33554432 bytes</span><br><span class="line">Redo Buffers                 667648 bytes</span><br><span class="line">Database mounted.</span><br><span class="line">Database opened.</span><br><span class="line">================================</span><br><span class="line">SQL&gt; select * from v$nls_parameters;</span><br><span class="line">================================</span><br><span class="line">略</span><br><span class="line">19 rows selected.</span><br><span class="line"></span><br><span class="line">D、client端字符集修改</span><br><span class="line"></span><br><span class="line">在 /home/oracle与 /root用户目录下的.bash_profile中</span><br><span class="line"></span><br><span class="line">添加或修改 export NLS_LANG="AMERICAN_AMERICA.UTF8" 语句</span><br><span class="line"></span><br><span class="line">关闭当前ssh窗口。</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--导出、导入</span></span><br><span class="line">exp</span><br><span class="line">imp cross_dev/sss@cross_test fromuser=cross_dev touser=cross_dev rows=y indexes=n ignore=y <span class="keyword">commit</span>=y <span class="keyword">file</span>=d:\cross_dev.dmp</span><br><span class="line"></span><br><span class="line"><span class="comment">--oracle server字符集</span></span><br><span class="line"><span class="keyword">select</span> userenv(<span class="string">'language'</span>) <span class="keyword">from</span> dual;</span><br><span class="line"></span><br><span class="line"><span class="comment">--oracle dmp字符集</span></span><br><span class="line">用oracle的exp工具导出的dmp文件也包含了字符集信息，dmp文件的第2和第3个字节记录了dmp文件的字符集。如果dmp文件不大，比如只有几M或几十M，</span><br><span class="line">可以用UltraEdit打开(16进制方式)，看第2第3个字节的内容，如0354，然后用以下SQL查出它对应的字符集:</span><br><span class="line"><span class="keyword">select</span> nls_charset_name(to_number(<span class="string">'0354'</span>,<span class="string">'xxxx'</span>)) <span class="keyword">from</span> dual;</span><br><span class="line">如果dmp文件很大，比如有2G以上(这也是最常见的情况)，用文本编辑器打开很慢或者完全打不开，可以用以下命令(在unix主机上):</span><br><span class="line">cat exp.dmp |od -x|head -1|awk '&#123;print $2 $3&#125;'|cut -c 3-6</span><br><span class="line">然后用上述SQL也可以得到它对应的字符集。</span><br><span class="line"></span><br><span class="line"><span class="comment">--oracle client端的字符集</span></span><br><span class="line">$echo $NLS_LANG</span><br><span class="line"></span><br><span class="line">(1).数据库服务器字符集</span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> nls_database_parameters</span><br><span class="line">来源于props$，是表示数据库的字符集。</span><br><span class="line"></span><br><span class="line">(<span class="number">2</span>).客户端字符集环境</span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> nls_instance_parameters</span><br><span class="line">其来源于v$parameter，表示客户端的字符集的设置，可能是参数文件，环境变量或者是注册表</span><br><span class="line"></span><br><span class="line">(<span class="number">3</span>).会话字符集环境</span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> nls_session_parameters</span><br><span class="line">来源于v$nls_parameters，表示会话自己的设置，可能是会话的环境变量或者是<span class="keyword">alter</span> <span class="keyword">session</span>完成，如果会话没有特殊的设置，将与nls_instance_parameters一致。</span><br><span class="line"></span><br><span class="line">(<span class="number">4</span>).客户端的字符集要求与服务器一致，才能正确显示数据库的非<span class="keyword">Ascii</span>字符。</span><br><span class="line">如果多个设置存在的时候，NLS作用优先级别：<span class="keyword">Sql</span> <span class="keyword">function</span> &gt; <span class="keyword">alter</span> <span class="keyword">session</span> &gt; 环境变量或注册表&gt; 参数文件&gt; 数据库默认参数</span><br><span class="line"></span><br><span class="line">字符集要求一致，但是语言设置却可以不同，语言设置建议用英文。如字符集是zhs16gbk，则nls_lang可以是American_America.zhs16gbk。</span><br><span class="line"></span><br><span class="line">============================导入数据=======================================================================================================</span><br><span class="line"><span class="comment">--登录oracle的sqlplus</span></span><br><span class="line">sqlplus / <span class="keyword">as</span> <span class="keyword">sysdba</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--查看主数据库归档日志的sequence是否一致</span></span><br><span class="line"><span class="keyword">select</span> <span class="keyword">max</span>(<span class="keyword">sequence</span><span class="comment">#) from v$archived_log;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">---查看当前的数据库文件（表空间）存放位置：</span></span><br><span class="line"> <span class="keyword">select</span> <span class="keyword">name</span> <span class="keyword">from</span> v$<span class="keyword">datafile</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--创建表空间</span></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">tablespace</span> yoonline <span class="keyword">datafile</span> <span class="string">'/data/app/oracle/oradata/orcl/yoonline01.dbf'</span> <span class="keyword">size</span> <span class="number">3072</span>m;</span><br><span class="line"></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">tablespace</span> yoonline <span class="keyword">datafile</span> <span class="string">'/data/app/oracle/oradata/yo/yoonline01.dbf'</span> <span class="keyword">size</span> <span class="number">4096</span>m;</span><br><span class="line"></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">tablespace</span> yotest <span class="keyword">datafile</span> <span class="string">'/data/app/oracle/oradata/orcl/yotest01.dbf'</span> <span class="keyword">size</span> <span class="number">4096</span>m;</span><br><span class="line">　3000m指的是3000MB,10G</span><br><span class="line"></span><br><span class="line"><span class="comment">--创建用户并指定表空间</span></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">user</span> yo_online <span class="keyword">identified</span> <span class="keyword">by</span> yo_online123 <span class="keyword">default</span> <span class="keyword">tablespace</span> yoonline;</span><br><span class="line"></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">user</span> yo_test <span class="keyword">identified</span> <span class="keyword">by</span> yo_test123 <span class="keyword">default</span> <span class="keyword">tablespace</span> yotest;</span><br><span class="line"></span><br><span class="line"><span class="comment">--给用户授权</span></span><br><span class="line"><span class="keyword">grant</span> dba,<span class="keyword">connect</span>,<span class="keyword">resource</span> <span class="keyword">to</span> yo_online;</span><br><span class="line"></span><br><span class="line"><span class="comment">--查询服务器端的字符集</span></span><br><span class="line"><span class="keyword">select</span> userenv(<span class="string">'language'</span>) <span class="keyword">from</span> dual;</span><br><span class="line"></span><br><span class="line"><span class="comment">--删除用户所有表</span></span><br><span class="line"><span class="keyword">select</span> <span class="string">'drop table '</span>||table_name||<span class="string">';'</span> <span class="keyword">from</span> cat <span class="keyword">where</span> table_type=<span class="string">'TABLE'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--退出sqlplus,设置client端字符集与服务端一致</span></span><br><span class="line">export NLS_LANG=AMERICAN_AMERICA.AL32UTF8</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--批量建表</span></span><br><span class="line"></span><br><span class="line">在命令窗口执行</span><br><span class="line">@（sql文件位置）</span><br><span class="line"></span><br><span class="line"><span class="comment">--关闭、启用外键</span></span><br><span class="line"><span class="keyword">select</span> <span class="string">'alter table '</span>||table_name||<span class="string">' enable constraint '</span>||constraint_name||<span class="string">';'</span> <span class="keyword">from</span> user_constraints <span class="keyword">where</span> constraint_type=<span class="string">'R'</span>;</span><br><span class="line"><span class="keyword">select</span> <span class="string">'alter table '</span>||table_name||<span class="string">' disable constraint '</span>||constraint_name||<span class="string">';'</span> <span class="keyword">from</span> user_constraints <span class="keyword">where</span> constraint_type=<span class="string">'R'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--禁用、启用用户创建的触发器</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="string">'alter trigger '</span>|| OBJECT_NAME ||<span class="string">' disable;'</span> <span class="keyword">FROM</span> DBA_OBJECTS <span class="keyword">WHERE</span> OBJECT_TYPE=<span class="string">'TRIGGER'</span> <span class="keyword">and</span> owner=<span class="string">'YO_ONLINE'</span> <span class="keyword">order</span> <span class="keyword">by</span> OBJECT_NAME;</span><br><span class="line"><span class="keyword">SELECT</span> <span class="string">'alter trigger '</span>|| OBJECT_NAME ||<span class="string">' enable;'</span> <span class="keyword">FROM</span> DBA_OBJECTS <span class="keyword">WHERE</span> OBJECT_TYPE=<span class="string">'TRIGGER'</span> <span class="keyword">and</span> owner=<span class="string">'YO_ONLINE'</span> <span class="keyword">order</span> <span class="keyword">by</span> OBJECT_NAME;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">--修改表的字段长度</span></span><br><span class="line"><span class="keyword">select</span> <span class="string">'ALTER TABLE '</span>||TABLE_NAME||<span class="string">' MODIFY '</span>||COLUMN_NAME||<span class="string">' VARCHAR2(1000);'</span> <span class="keyword">from</span> user_tab_columns <span class="keyword">where</span> data_type=<span class="string">'VARCHAR2'</span> <span class="keyword">AND</span> DATA_LENGTH&gt;=<span class="number">100</span> <span class="keyword">AND</span> DATA_LENGTH&lt;<span class="number">1000</span> <span class="keyword">and</span> TABLE_NAME <span class="keyword">like</span> <span class="string">'T%'</span>;</span><br><span class="line"><span class="keyword">select</span> <span class="string">'ALTER TABLE '</span>||TABLE_NAME||<span class="string">' MODIFY '</span>||COLUMN_NAME||<span class="string">' VARCHAR2(200);'</span> <span class="keyword">from</span> user_tab_columns <span class="keyword">where</span> data_type=<span class="string">'VARCHAR2'</span> <span class="keyword">AND</span> DATA_LENGTH&lt;<span class="number">100</span> <span class="keyword">and</span> TABLE_NAME <span class="keyword">like</span> <span class="string">'T%'</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">### expdp导出 impdp导入数据</span></span><br><span class="line">sqlplus / as sysdba</span><br><span class="line"><span class="keyword">execute</span> dbms_metadata_util.load_stylesheets;</span><br><span class="line"></span><br><span class="line">expdp yogs/yogsdbserver@orcl TABLES=t_bs_test dumpfile=expdp.dmp logfile=expdp.log DIRECTORY=dpdata;</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="扩展表空间"><a href="#扩展表空间" class="headerlink" title="扩展表空间"></a>扩展表空间</h2><h3 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h3><ul>
<li><p>首先查看表空间的名字和所属文件</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> tablespace_name, file_id, file_name,<span class="keyword">round</span>(<span class="keyword">bytes</span>/(<span class="number">1024</span>*<span class="number">1024</span>),<span class="number">0</span>) total_space</span><br><span class="line"><span class="keyword">from</span> dba_data_files</span><br><span class="line"><span class="keyword">order</span> <span class="keyword">by</span> tablespace_name;</span><br></pre></td></tr></table></figure>
</li>
<li><p>查看表空间的使用情况</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> <span class="keyword">SUM</span>(<span class="keyword">bytes</span>) / (<span class="number">1024</span> * <span class="number">1024</span>) <span class="keyword">AS</span> free_space, tablespace_name</span><br><span class="line"><span class="keyword">FROM</span> dba_free_space</span><br><span class="line"><span class="keyword">GROUP</span> <span class="keyword">BY</span> tablespace_name;</span><br><span class="line"><span class="keyword">SELECT</span> a.tablespace_name,</span><br><span class="line">a.bytes total,</span><br><span class="line">b.bytes used,</span><br><span class="line">c.bytes free,</span><br><span class="line">(b.bytes * <span class="number">100</span>) / a.bytes <span class="string">"% USED "</span>,</span><br><span class="line">(c.bytes * <span class="number">100</span>) / a.bytes <span class="string">"% FREE "</span></span><br><span class="line"><span class="keyword">FROM</span> sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c</span><br><span class="line"><span class="keyword">WHERE</span> a.tablespace_name = b.tablespace_name</span><br><span class="line"><span class="keyword">AND</span> a.tablespace_name = c.tablespace_name;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="1-增加数据文件"><a href="#1-增加数据文件" class="headerlink" title="1.增加数据文件"></a>1.增加数据文件</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLESPACE</span> game <span class="keyword">ADD</span> <span class="keyword">DATAFILE</span> <span class="string">'/oracle/oradata/db/GAME02.dbf'</span> <span class="keyword">SIZE</span> <span class="number">1000</span>M;</span><br><span class="line"></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">TABLESPACE</span> YOONLINE <span class="keyword">ADD</span> <span class="keyword">DATAFILE</span> <span class="string">'/data/oradata/yo/yoonline01.dbf'</span> <span class="keyword">SIZE</span> <span class="number">20480</span>M;</span><br></pre></td></tr></table></figure>
<h3 id="2-手动增加数据文件尺寸"><a href="#2-手动增加数据文件尺寸" class="headerlink" title="2.手动增加数据文件尺寸"></a>2.手动增加数据文件尺寸</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">DATAFILE</span> <span class="string">'/oracle/oradata/db/GAME.dbf'</span> <span class="keyword">RESIZE</span> <span class="number">4000</span>M;</span><br><span class="line"></span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">DATAFILE</span> <span class="string">'/data/oradata/yo/yoonline01.dbf'</span> <span class="keyword">RESIZE</span> <span class="number">20480</span>M;</span><br></pre></td></tr></table></figure>
<h3 id="3-设定数据文件自动扩展"><a href="#3-设定数据文件自动扩展" class="headerlink" title="3.设定数据文件自动扩展"></a>3.设定数据文件自动扩展</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">DATAFILE</span> <span class="string">'/oracle/oradata/db/GAME.dbf'</span> <span class="keyword">AUTOEXTEND</span> <span class="keyword">ON</span> <span class="keyword">NEXT</span> <span class="number">100</span>M <span class="keyword">MAXSIZE</span> <span class="number">10000</span>M;</span><br></pre></td></tr></table></figure>
<h3 id="设定后查看表空间信息"><a href="#设定后查看表空间信息" class="headerlink" title="设定后查看表空间信息"></a>设定后查看表空间信息</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">SELECT</span> A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED,C.BYTES FREE,(B.BYTES*<span class="number">100</span>)/A.BYTES <span class="string">"% USED"</span>,(C.BYTES*<span class="number">100</span>)/A.BYTES <span class="string">"% FREE"</span></span><br><span class="line"><span class="keyword">FROM</span> SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C</span><br><span class="line"><span class="keyword">WHERE</span> A.TABLESPACE_NAME=B.TABLESPACE_NAME <span class="keyword">AND</span> A.TABLESPACE_NAME=C.TABLESPACE_NAME;</span><br></pre></td></tr></table></figure>
<h3 id="启动oracle"><a href="#启动oracle" class="headerlink" title="启动oracle"></a>启动oracle</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">sqlplus /as sysdba</span><br><span class="line">sqlplus / as sysdba</span><br><span class="line">startup</span><br><span class="line"></span><br><span class="line">lsnrctl start</span><br><span class="line"></span><br><span class="line">/sbin/iptables -I INPUT -p tcp --dport 1521 -j ACCEPT</span><br><span class="line">/etc/init.d/iptables stop</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="导入备份数据"><a href="#导入备份数据" class="headerlink" title="导入备份数据"></a>导入备份数据</h3><ul>
<li><p>切换用户</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">su oracle</span><br></pre></td></tr></table></figure>
</li>
<li><p>环境变量生效  到~目录(当前登录用户目录)</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">source</span> ./bash-profie</span><br><span class="line"><span class="comment">#或者 source .bash_profile</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>导入数据</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">imp 用户/密码 fromuser=备份数据用户 touser=要导入数据的用户 rows=y indexes=n ignore=y commit=y file=dmp文件地址</span><br><span class="line"><span class="comment"># 如果导入数据量大 加入 feedback=10000 buffer=20480000 参数可以根据实际情况调整</span></span><br><span class="line"><span class="comment"># 例子</span></span><br><span class="line">./imp yo_test/yo_test123 fromuser=yo_online touser=yo_test rows=y indexes=n ignore=y commit=y feedback=10000 buffer=20480000 file=/data/orabak/oracleBack_201605222219.dmp</span><br></pre></td></tr></table></figure>
</li>
</ul>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/运维/" rel="tag"># 运维</a>
          
            <a href="/tags/oracle/" rel="tag"># oracle</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/06/09/spring-d/" rel="next" title="SpingBoot 程序 部署">
                <i class="fa fa-chevron-left"></i> SpingBoot 程序 部署
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/10/15/nodejs-file-servier/" rel="prev" title="Node js 文件服务器">
                Node js 文件服务器 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.png" alt="李磊">
            
              <p class="site-author-name" itemprop="name">李磊</p>
              <p class="site-description motion-element" itemprop="description">不做键盘侠！！！</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">23</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/mylyed" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github-alt"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://git.oschina.net/lil" target="_blank" title="码云">
                      
                        <i class="fa fa-fw fa-gitlab"></i>码云</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="http://weibo.com/u/2168032422" target="_blank" title="微博">
                      
                        <i class="fa fa-fw fa-weibo"></i>微博</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.zhihu.com/people/li-cai-40-13" target="_blank" title="知乎">
                      
                        <i class="fa fa-fw fa-globe"></i>知乎</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#bash脚本"><span class="nav-number">1.</span> <span class="nav-text">bash脚本</span></a></li></ol><li class="nav-item nav-level-2"><a class="nav-link" href="#扩展表空间"><span class="nav-number"></span> <span class="nav-text">扩展表空间</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#准备"><span class="nav-number">1.</span> <span class="nav-text">准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-增加数据文件"><span class="nav-number">2.</span> <span class="nav-text">1.增加数据文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-手动增加数据文件尺寸"><span class="nav-number">3.</span> <span class="nav-text">2.手动增加数据文件尺寸</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-设定数据文件自动扩展"><span class="nav-number">4.</span> <span class="nav-text">3.设定数据文件自动扩展</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#设定后查看表空间信息"><span class="nav-number">5.</span> <span class="nav-text">设定后查看表空间信息</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#启动oracle"><span class="nav-number">6.</span> <span class="nav-text">启动oracle</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#导入备份数据"><span class="nav-number">7.</span> <span class="nav-text">导入备份数据</span></a></li></ol></li></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2017 &mdash; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user-secret"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">李磊</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a></div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      本站访客数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      本站总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.3"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.3"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.3"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  












  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

</body>
</html>
